<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增题目</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/admin.css">
</head>
<body>
<div style="padding: 15px;">
    <form class="bs-example bs-example-form">
        <table class="table">
            <tr>
                <td></td>
                <td>
                    <input type="number" class="form-control" name="sort" placeholder="请输入序列号">
                    <input type="hidden" class="form-control" name="secondSubId" value=''>
                </td>
            </tr>
        </table>
        <button class="btn btn-primary btn-lg btn-block" type='button' onclick='OrderInfo()'>提交保存</button>
    </form>
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/layer/layer.js"></script>
<script>
    function OrderInfo(){
        var secondSubId=$('input[name=secondSubId]').val(),
            sort=$('input[name=sort]').val();
        if(!secondSubId){
            layer.msg('参数错误',{icon: 2,time:1000});
            setTimeout(function(){parent.location.reload();},1000);
            return false;
        }
        if(!sort || sort<='0'){
            layer.msg('请严格输入序列号',{icon: 2,time:1000});
            $('input[name=sort]').focus();
            return false;
        }
        var data = [];
        data.push({id:secondSubId,sorder:sort});
        $.ajax({
            type:'put',
            contentType: 'application/json;charset=UTF-8',
            dataType:'json',
            url : "/secondType/relateSub",
            data:  JSON.stringify(data),
            success: function(json){
                if(json.status=="success"){
                    var index = layer.load(1, {
                        shade: [0.1,'#fff']
                    });
                    layer.msg('操作成功', {icon: 1, time: 1000});
                    setTimeout(function () {
                        var index=window.parent.layer.getFrameIndex(window.name);
                        window.parent.layer.close(index);
                    }, 1200);
                }else{
                    layer.msg(json.msg,{icon: 2,time:1000});
                }
            },
            error:function (){
                layer.msg('网络连接失败',{icon: 5,area: ['', '15%'],time:1000});
            }
        });
    }
</script>
</body>
</html>